]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
extensionSystem: Create a file to flag that extensions are being loaded
authorBenjamin Berg <bberg@redhat.com>
Mon, 25 Nov 2019 20:20:02 +0000 (21:20 +0100)
committerFlorian Müllner <florian.muellner@gmail.com>
Mon, 25 Nov 2019 21:49:49 +0000 (21:49 +0000)
When the extension system is loaded, create the
gnome-shell-disable-extensions file in the users runtime directory. This
file is automatically removed 60s later. The sole purpose of this file
is to be consumed by the systemd units. If the file exists, the systemd
units will disable extensions when the gnome-shell fails.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/858

js/ui/extensionSystem.js

index c56bfdf059e9a0d1cb3ce01187534a7d164a1c24..f9fc71b76ad3ceb0351234756187019477e7c1d4 100644 (file)
@@ -1,7 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 /* exported init connect disconnect */
 
-const { Gio, St } = imports.gi;
+const { GLib, Gio, St } = imports.gi;
 const Signals = imports.signals;
 
 const ExtensionUtils = imports.misc.extensionUtils;
@@ -28,6 +28,23 @@ var ExtensionManager = class {
     }
 
     init() {
+        // The following file should exist for a period of time when extensions
+        // are enabled after start. If it exists, then the systemd unit will
+        // disable extensions should gnome-shell crash.
+        // Should the file already exist from a previous login, then this is OK.
+        let disableFilename = GLib.build_filenamev([GLib.get_user_runtime_dir(), 'gnome-shell-disable-extensions']);
+        let disableFile = Gio.File.new_for_path(disableFilename);
+        try {
+            disableFile.create(Gio.FileCreateFlags.REPLACE_DESTINATION, null);
+        } catch (e) {
+            log(`Failed to create file ${disableFilename}: ${e.message}`);
+        }
+
+        GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 60, () => {
+            FileUtils.deleteGFile(disableFile);
+            return GLib.SOURCE_REMOVE;
+        });
+
         this._sessionUpdated();
     }